package chen.web.config.spring;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import chen.web.event.EventSupport;
import chen.web.user.AccountManager;
import chen.web.user.AccountManagerImpl;
import chen.web.user.AccountManagerEventFirer;
import chen.web.user.InternalAccountProvider;
import chen.web.user.RoleManager;
import chen.web.user.SecurityAccountManager;
import chen.web.user.CachedAccountManager;


@Configuration
public class AccountManagerConfig {

	private @Autowired RoleManager rm;
	private @Autowired EventSupport es;
	
	//账号管理
	public @Bean AccountManager accountManager(){
		AccountManager accountManager = new SecurityAccountManager(new AccountManagerEventFirer(new CachedAccountManager(new AccountManagerImpl(rm)),es));
		InternalAccountProvider.setAccoutManager(accountManager);
		return accountManager;
	}
}
